<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    $echoStr = $_GET["echostr"];


    echo $echoStr;
    dd('exit');
});
Route::any('wechats','Wechat\WechatController@index');
//微信或支付宝授权
Route::get('wx-or-ali-auth/{merchant_id?}','Auth\AuthUserInfoController@getUserInfo')->name('WAauth');
Route::get('auth-callback/{merchant_id?}','Auth\AuthUserInfoController@authCallback');

//会员卡列表页
Route::get('user/card-list','UserCenterController@cardList')->name('uCardList')->middleware('wxorali');
//绑定手机号->middleware('wxorali');
Route::get('bind-phone/{merchant_id?}','UserCenterController@bindPhone')->name('bindPhone')->middleware('wxorali');
//选择会员卡进入
Route::get('/user/wxcard-login','UserCenterController@wxcardLogin');

Route::group(['middleware'=>'checkwxusermcard'],function (){
    //绑定会员信息
    Route::get('bind-user-info','UserCenterController@bindUserInfo')->name('bindUInfo');

    //会员中心 ->middleware(['wxorali','checkphone']);
    Route::get('user-center/{merchant_id?}','UserCenterController@index')->name('ucenter');
    //修改用户信息
    Route::get('user/edit','UserCenterController@edit')->name('uedit');
    Route::match(['patch','post'],'user/edit','UserCenterController@update')->name('uupdate');
    //打卡
    Route::get('user/punch-clock','UserCenterController@punchClock')->name('pclock');
    //积分 ucredits
    Route::get('user/credits','UserCenterController@credits')->name('ucredits');
    //会员码
    Route::get('user/member-qrcode','UserCenterController@memberQrcode')->name('umemberQrcode');
    //电子钱包 uwallet
    Route::get('user/wallet','UserCenterController@wallet')->name('uwallet');
    //余额明细
    Route::get('user/balance-record','UserCenterController@balanceRecord')->name('uBalanceRecord');
    //消费券列表
    Route::get('user/my_ticktes','UserCenterController@myTicktes')->name('uTicktes');

    //权益详情
    Route::get('user/{id_wxcard_prerogative}/card-power-detail','UserCenterController@powerDetail')->name('prowerDetail');

    //权益说明
    Route::get('card-power-explain','UserCenterController@powerExplain')->name('powerExplain');

    //礼品卡区 ugift
    Route::get('order/gift','OrderController@gift')->name('ogift');
    //购买礼平卡
    Route::get('order/buy/{id_gift}/gift','OrderController@buyGiftCard')->where('id_gift','[0-9]+');
    //绑卡记录
    Route::get('order/gift_record','OrderController@giftRecord')->name('oGiftRecord');

    //订单列表
    Route::get('order/list','OrderController@orderList')->name('oList');
    //购物小票
    Route::get('order/receipt/{billno}','OrderController@receipt')->name('Oreceipt')->where('billno','[0-9]+');
    //积分兑换
    Route::get('order/credit_exchange','OrderController@creditExchange')->name('oExchange');
    //兑换记录
    Route::get('order/credits_exchange_recode','OrderController@exchangeRecode')->name('oExchangeRecode');
    //余额充值
    Route::get('order/recharge-balance','OrderController@rechargeBalance')->name('rechargeBalance');
    Route::get('order/withdraw-balance','OrderController@withdrawBalance')->name('withdrawBalance');
    //我的服务
    Route::get('my-service','ServiceController@index');
    //电子发票
    Route::get('service/invoice','ServiceController@invoice')->name('invoice');
    Route::get('service/invoice-form','ServiceController@invoiceForm')->name('invoiceForm');
});


//->middleware('checksession')
Route::prefix('ajax')->middleware('checksession')->namespace('Ajax')->group(function(){
    //短信验证码
    Route::post('verificationCodes','VerificationCodesController@store');
    //验证手机验证码
    Route::post('validateCode','VerificationCodesController@validateCode');
    //会员码
    Route::post('getConsumeCode','AboutUserController@getConsumeQrcodeText');
    //获取积分记录列表
    Route::post('getCreditsRecords','AboutUserController@getCreditsRecords');
    //获取余额记录列表
    Route::post('getBalanceRecords','AboutUserController@getBalanceRecords');
    //生日特权领取奖品
    Route::post('birthday-gift/get','AboutUserController@getBirthdayGift');
    //打卡
    Route::post('punch-clock','AboutUserController@punchClock');
    //获取连续打卡奖励
    Route::post('punch-clock/get-continue-gift','AboutUserController@getContinuegGift');
    //获取当月打卡记录
    Route::post('get-clock-record','AboutUserController@monthClockRecord');

    //积分兑换
    Route::post('credits-exchange','AboutOrderController@creditsExchange');

    //购买礼平卡
    Route::post('pay/gift-card','AboutPayController@buyGiftCard');
    //绑定礼品卡
    Route::post('bind/gift-card','AboutOrderController@bindGiftCard');
});

//测试富基接口
Route::resource('test','TestController');
//Route::get('/test', 'TestController@index')->name('users.index');
//测试发票接口
Route::get('testinvoice','InvoiceController@store');
Route::get('queryinvoice','InvoiceController@query');

//测试微信
Route::get('testwechat','TestWechatController@auth');
Route::get('testwechat/otherauth','TestWechatController@otherAuth');
Route::get('testwechat/authcallback','TestWechatController@authCallback');
Route::get('testwechat/otherauthcallback','TestWechatController@otherAuthCallback');
Route::get('testwechat/info','TestWechatController@info');